import styled from 'styled-components'

interface Istate {
  $direction: 'left' | 'right' | 'top' | 'bottom'
  $size: string
  $borderRadius: string
  $bgclor: string
}

export const LtDrawerWrapper = styled.div<Istate>`
  .mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .drawer {
    position: fixed;
    ${(props) => {
      switch (props.$direction) {
        case 'left':
          return `
          left: 0;
          top: 0;
          bottom: 0;
          border-radius:0  ${props.$borderRadius}  ${props.$borderRadius} 0;
          width: ${props.$size};
          `
        case 'right':
          return `
          right: 0;
          top: 0;
          bottom: 0;
          border-radius: ${props.$borderRadius} 0 0  ${props.$borderRadius};
          width:${props.$size};
          `
        case 'top':
          return `
          top: 0;
          right: 0;
          left: 0;
          border-radius: 0 0  ${props.$borderRadius} ${props.$borderRadius};
          height: ${props.$size};
          `
        case 'bottom':
          return `
          bottom: 0;
          left: 0;
          right: 0;
          border-radius: ${props.$borderRadius} ${props.$borderRadius} 0 0  ;
          height: ${props.$size};
          `
      }
    }}
    z-index: 99999;
    padding: 20px;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    background-color: ${(props) => props.$bgclor};
  }

  .mask-enter {
    opacity: 0;
  }

  .mask-enter-active {
    opacity: 1;
    transition: opacity 300ms ease-in;
  }

  .mask-exit {
    opacity: 1;
  }

  .mask-exit-active {
    opacity: 0;
    transition: opacity 300ms ease-out;
  }

  .drawer-enter {
    opacity: 0;
    /* 根据方向判断出现的位置 */
    ${(props) => {
      switch (props.$direction) {
        case 'left':
          return `
          transform: translateX(-100%);`
        case 'right':
          return `
          transform: translateX(100%);`
        case 'top':
          return `
          transform: translateY(-100%);`
        case 'bottom':
          return `transform: translateY(100%);`
      }
    }}
  }
  .drawer-enter-active {
    opacity: 1;
    ${(props) => {
      switch (props.$direction) {
        case 'left':
          return `
          transform: translateX(0);`
        case 'right':
          return `
          transform: translateX(0);`
        case 'top':
          return `
          transform: translateY(0);`
        case 'bottom':
          return `transform: translateY(0);`
      }
    }}
    transition: all 0.3s ease;
  }
  .drawer-exit {
    opacity: 1;
    ${(props) => {
      switch (props.$direction) {
        case 'left':
          return `
          transform: translateX(0);`
        case 'right':
          return `
          transform: translateX(0);`
        case 'top':
          return `
          transform: translateY(0);`
        case 'bottom':
          return `transform: translateY(0);`
      }
    }}
  }
  .drawer-exit-active {
    opacity: 0;
    ${(props) => {
      switch (props.$direction) {
        case 'left':
          return `
          transform: translateX(-100%);`
        case 'right':
          return `
          transform: translateX(100%);`
        case 'top':
          return `
          transform: translateY(-100%);`
        case 'bottom':
          return `transform: translateY(100%);`
      }
    }}
    transition: all 0.3s ease;
  }

  .drawer::-webkit-scrollbar {
    display: none;
  }
`
